package flc.ast.adapter;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.AppUtils;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyAppBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class AppAdapter extends StkProviderMultiAdapter<MyAppBean> {

    public AppAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(150));
        addItemProvider(new AppProvider());
    }


    private class AppProvider extends BaseItemProvider<MyAppBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_app;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyAppBean bean) {
            baseViewHolder.setImageDrawable(R.id.ivAppItemImg,AppUtils.getAppIcon(bean.getName()));
            baseViewHolder.setText(R.id.tvAppItemName,AppUtils.getAppName(bean.getName()));
        }
    }
}
